package view.readerView;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import view.logOnView.LogOnFrm1;
import view.systemAdmiView.BookSearchInterFrm;
import view.systemAdmiView.UserImfAddInterFrm;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import java.awt.Font;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JDesktopPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;
import java.awt.Toolkit;

public class ReaderMainFrm extends JFrame {

	private JPanel contentPane;
	

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ReaderMainFrm frame = new ReaderMainFrm();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public ReaderMainFrm() {
		setIconImage(Toolkit.getDefaultToolkit().getImage(ReaderMainFrm.class.getResource("/images/readerAdim/借阅者.png")));
		setTitle("借阅者界面");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1416, 766);
		
		JDesktopPane table = new JDesktopPane();
		table.setBackground(new Color(230, 230, 250));
		
		JMenuBar readermenuBar = new JMenuBar();
		readermenuBar.setBackground(new Color(127, 255, 212));
		setJMenuBar(readermenuBar);
		
		JMenu userImfMenu = new JMenu("  个人信息                     ");
		userImfMenu.setIcon(new ImageIcon(ReaderMainFrm.class.getResource("/images/readerAdim/个人信息设置.png")));
		userImfMenu.setFont(new Font("微软雅黑", Font.BOLD, 28));
		readermenuBar.add(userImfMenu);
		
		JMenuItem userImfSearchMenuItem = new JMenuItem("查看个人信息");
		userImfSearchMenuItem.setIcon(new ImageIcon(ReaderMainFrm.class.getResource("/images/readerAdim/个人信息查询.png")));
		userImfSearchMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				UserImfSearchInterFrm userImfSearchInterFrm=new UserImfSearchInterFrm();
				userImfSearchInterFrm.setVisible(true);
				table.add(userImfSearchInterFrm);
				
				
			}
		});
		userImfSearchMenuItem.setFont(new Font("宋体", Font.BOLD, 28));
		userImfMenu.add(userImfSearchMenuItem);
		
		JMenu borrowImfMenu = new JMenu(" 借阅信息                ");
		borrowImfMenu.setIcon(new ImageIcon(ReaderMainFrm.class.getResource("/images/bookAdmi/信息查询 (2).png")));
		borrowImfMenu.setFont(new Font("微软雅黑", Font.BOLD, 28));
		readermenuBar.add(borrowImfMenu);
		
		JMenuItem borrowImfSearchMenuItem = new JMenuItem("查询图书借阅信息");
		borrowImfSearchMenuItem.setIcon(new ImageIcon(ReaderMainFrm.class.getResource("/images/bookAdmi/借阅查询 .png")));
		borrowImfSearchMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				BorrowImfSearchInterFrm borrowImfSearchInterFrm=new BorrowImfSearchInterFrm();
				borrowImfSearchInterFrm.setVisible(true);
				table.add(borrowImfSearchInterFrm);
			}
		});
		borrowImfSearchMenuItem.setFont(new Font("宋体", Font.BOLD, 28));
		borrowImfMenu.add(borrowImfSearchMenuItem);
		
		JMenu bookSearchMenu = new JMenu(" 图书查询                       ");
		bookSearchMenu.setIcon(new ImageIcon(ReaderMainFrm.class.getResource("/images/bookAdmi/信息查询 (1).png")));
		bookSearchMenu.setFont(new Font("微软雅黑", Font.BOLD, 28));
		readermenuBar.add(bookSearchMenu);
		
		JMenuItem bookSearchImfMenuItem = new JMenuItem("查询图书信息");
		bookSearchImfMenuItem.setIcon(new ImageIcon(ReaderMainFrm.class.getResource("/images/bookAdmi/图书查询_intouch.png")));
		bookSearchImfMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				BookSearchInterFrm bookSearchInterFrm=new BookSearchInterFrm();
				bookSearchInterFrm.setVisible(true);
				table.add(bookSearchInterFrm);
			}
		});
		bookSearchImfMenuItem.setFont(new Font("宋体", Font.BOLD, 28));
		bookSearchMenu.add(bookSearchImfMenuItem);
		
		JMenu logOffMenu = new JMenu("安全退出");
		logOffMenu.setIcon(new ImageIcon(ReaderMainFrm.class.getResource("/images/退出登录 (1).png")));
		logOffMenu.setFont(new Font("微软雅黑", Font.BOLD, 28));
		readermenuBar.add(logOffMenu);
		
		JMenuItem logOffMenuItem = new JMenuItem("退出登录");
		logOffMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				int result=JOptionPane.showConfirmDialog(null, "是否退出登录");
//				System.out.println(result);    可以利用输出进行断点调试
				if(result==0) {
					dispose();
					LogOnFrm1 logOnFrm=new LogOnFrm1();
					logOnFrm.setVisible(true);
				}
			}
		});
		logOffMenuItem.setIcon(new ImageIcon(ReaderMainFrm.class.getResource("/images/bookAdmi/退出登录.png")));
		logOffMenuItem.setFont(new Font("宋体", Font.BOLD, 28));
		logOffMenu.add(logOffMenuItem);
		
		JMenuItem logOffSystemMenuItem = new JMenuItem("退出系统");
		logOffSystemMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				int result=JOptionPane.showConfirmDialog(null, "是否退出系统");
//				System.out.println(result);    可以利用输出进行断点调试
				if(result==0) {
					dispose();
					
				}
			}
		});
		logOffSystemMenuItem.setIcon(new ImageIcon(ReaderMainFrm.class.getResource("/images/bookAdmi/退出登录.png")));
		logOffSystemMenuItem.setFont(new Font("宋体", Font.BOLD, 28));
		logOffMenu.add(logOffSystemMenuItem);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new BorderLayout(0, 0));
		
		
		contentPane.add(table, BorderLayout.CENTER);
		
		//设置JFrame最大化
		this.setExtendedState(JFrame.MAXIMIZED_BOTH);
	}
}
